package com.ra.util;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.espirit.eap.manager.DictionaryService;
import com.googlecode.cswish.annotation.Rest;
import com.googlecode.cswish.struts.spring.GenericService;
import com.ra.coupon.Coupon;
import com.ra.landlord.LandlordOwnerUser;
import com.ra.landlord.constant.LandlordConstant;
import com.ra.landlord.vo.OrderVO;

/**
 * SMS utility class
 * 
 * @author colin 2015-09-14
 * 
 */
@Service
public class CommonService {
	
	@Resource
	private DictionaryService dictionaryService;
	
	@Resource
	private GenericService genericService;
	
	/**
	 * 获取品牌公寓首页描述
	 * @param name
	 * @return
	 */
	@Rest(simpleServiceName = "anonymity", type = "free")
	public String getValueByTypeName(String type, String name){
		return dictionaryService.getValueByTypeName(type, name);
	}
	
	/**
	 * 补全OrderVO
	 * @param vo
	 * @param landlordUser
	 * @return
	 */
	public OrderVO completeOrderVO(OrderVO vo){
		
		if (vo != null && vo.getLandlordUser() != null &&
				vo.getLandlordUser().getAttendMilliActivity() != null 
				&& vo.getLandlordUser().getAttendMilliActivity()) {
			Coupon modelCoupon = new Coupon();
			modelCoupon.setActivity(LandlordConstant.MILLIACTIVITY_DESC);
			List<Coupon> coupons = genericService.searchAll(modelCoupon).getData();
			vo.setCoupons(coupons);
		}
		return vo;
	}
	
}
